/**
 * Copyright (C) 2010 - 2013 Harry Glasgow
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.googlecode.jaden.ui;

import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

public class Jaden {
    public static void main(String[] args) {
        checkJavaVersion();
        initLogging();
        new UI().setVisible(true);
    }

    private static void checkJavaVersion() {
        String javaVersion = System.getProperty("java.version");
        String[] strings = javaVersion.split("\\.");
        if (strings.length < 2) {
            throw new IllegalStateException("Could not determine Java version: "
                    + javaVersion);
        } else if (Integer.parseInt(strings[1]) < 7) {
            throw new IllegalStateException("Java version must be 1.7 or above");
        }
    }

    private static void initLogging() {
        try {
            Handler fh = new FileHandler("%h/Jaden.log");
            fh.setFormatter(new SimpleFormatter());
            Logger.getLogger("").addHandler(fh);
        } catch (Exception e) {
            // Well, now what?
            e.printStackTrace();
        }
    }

}
